<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>北宋、明清进士空间分析 - Libido Chateau</title>
  <meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">


<meta name="author" content="迷幻主义搬砖号子" /><meta name="description" content="利用哈佛地理可视化平台、中国历代人物传记数据库的标记数据集，以及“发现中国”导出的地理数据，绘制北宋、明、清的进士来源地，以及它们比重的历时变迁。莆田是进士第一来源地，但至清时，福建、江西的比重已经不高。" /><meta name="keywords" content="数据, 时评, 人文" />


<meta name="baidu-site-verification" content="k5CktWnwfR" />
<meta name="google-site-verification" content="lO7fVN8Jm2sjiBOcR2knmNBKjtWcxS6KbuZYl2yELwA" />


<meta name="generator" content="Hugo 0.108.0 with theme even" />


<link rel="canonical" href="https://madlogos.github.io/post/song_ming_qing_jinshi/" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">

<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

<link href="/sass/main.min.67ad89b7ca43747ca0757fa0c720e4a26dfb092d0c625a7e1f3b937263f7d48d.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" integrity="sha256-Vzbj7sDDS/woiFS3uNKo8eIuni59rjyNGtXfstRzStA=" crossorigin="anonymous">
<link rel="stylesheet" href="/css/custom.css">


<meta property="og:title" content="北宋、明清进士空间分析" />
<meta property="og:description" content="利用哈佛地理可视化平台、中国历代人物传记数据库的标记数据集，以及“发现中国”导出的地理数据，绘制北宋、明、清的进士来源地，以及它们比重的历时变迁。莆田是进士第一来源地，但至清时，福建、江西的比重已经不高。" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://madlogos.github.io/post/song_ming_qing_jinshi/" /><meta property="article:section" content="post" />
<meta property="article:published_time" content="2017-04-23T00:00:00+00:00" />
<meta property="article:modified_time" content="2021-05-09T21:28:26+08:00" />


<meta itemprop="name" content="北宋、明清进士空间分析">
<meta itemprop="description" content="利用哈佛地理可视化平台、中国历代人物传记数据库的标记数据集，以及“发现中国”导出的地理数据，绘制北宋、明、清的进士来源地，以及它们比重的历时变迁。莆田是进士第一来源地，但至清时，福建、江西的比重已经不高。"><meta itemprop="datePublished" content="2017-04-23T00:00:00+00:00" />
<meta itemprop="dateModified" content="2021-05-09T21:28:26+08:00" />
<meta itemprop="wordCount" content="5962">
<meta itemprop="keywords" content="进士,地理分析," /><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="北宋、明清进士空间分析"/>
<meta name="twitter:description" content="利用哈佛地理可视化平台、中国历代人物传记数据库的标记数据集，以及“发现中国”导出的地理数据，绘制北宋、明、清的进士来源地，以及它们比重的历时变迁。莆田是进士第一来源地，但至清时，福建、江西的比重已经不高。"/>

<!--[if lte IE 9]>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
<![endif]-->

<!--[if lt IE 9]>
  <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->

</head>
<body>
  <div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/" class="logo">Libido Chateau</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>
<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    <a href="/">
        <li class="mobile-menu-item">首页</li>
      </a><a href="/post/">
        <li class="mobile-menu-item">归档</li>
      </a><a href="/tags/">
        <li class="mobile-menu-item">标签</li>
      </a><a href="/categories/">
        <li class="mobile-menu-item">分类</li>
      </a><a href="/about/">
        <li class="mobile-menu-item">关于</li>
      </a>
  </ul>

  


</nav>

  <div class="container" id="mobile-panel">
    <header id="header" class="header">
        <div class="logo-wrapper">
  <a href="/" class="logo">Libido Chateau</a>
</div>





<nav class="site-navbar">
  <ul id="menu" class="menu">
    <li class="menu-item">
        <a class="menu-item-link" href="/">首页</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/post/">归档</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/tags/">标签</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/categories/">分类</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/about/">关于</a>
      </li>
  </ul>
</nav>

    </header>

    <main id="main" class="main">
      <div class="content-wrapper">
        <div id="content" class="content">
          <article class="post">
    
    <header class="post-header">
      <h1 class="post-title">北宋、明清进士空间分析</h1>

      <div class="post-meta">
        <span class="post-time"> 2017-04-23 </span>
        <div class="post-category">
            <a href="/categories/%E6%95%B0%E6%8D%AE/"> 数据 </a>
            </div>
          <span class="more-meta"> 约 5962 字 </span>
          <span class="more-meta"> 预计阅读 12 分钟 </span>
        <span id="busuanzi_container_page_pv" class="more-meta"> <span id="busuanzi_value_page_pv"><img src="/img/spinner.svg" alt="spinner.svg"/></span> 次阅读 </span>
      </div>
    </header>

    <div class="post-toc" id="post-toc">
  <h2 class="post-toc-title">文章目录</h2>
  <div class="post-toc-content always-active">
    <nav id="TableOfContents">
  <ul>
    <li><a href="#哈佛人文地理可视化平台">哈佛人文地理可视化平台</a></li>
    <li><a href="#进士最大来源地">进士最大来源地？</a>
      <ul>
        <li><a href="#北宋">北宋</a></li>
        <li><a href="#明朝">明朝</a></li>
        <li><a href="#清朝">清朝</a></li>
      </ul>
    </li>
    <li><a href="#地理可视化">地理可视化</a>
      <ul>
        <li><a href="#当代疆域">当代疆域</a></li>
        <li><a href="#古代疆域">古代疆域</a></li>
        <li><a href="#进士来源地">进士来源地</a></li>
      </ul>
    </li>
    <li><a href="#来源地的时间趋势">来源地的时间趋势</a>
      <ul>
        <li><a href="#cbdb数据库">CBDB数据库</a></li>
        <li><a href="#北宋-1">北宋</a></li>
        <li><a href="#明朝-1">明朝</a></li>
        <li><a href="#清朝-1">清朝</a></li>
      </ul>
    </li>
    <li><a href="#姓氏">姓氏</a></li>
  </ul>
</nav>
  </div>
</div>
    <div class="post-content">
      <h2 id="哈佛人文地理可视化平台">哈佛人文地理可视化平台</h2>
<p>周末找在线GIS素材，误打误撞进到了worldmap.harvard.edu——一座名副其实的学术宝库。它是哈佛大学搞的一个<strong>开源</strong>地理可视化平台，社会、经济、历史学科的学者可以自己创建、上传数据集，方便地做多图层地理可视化。这个设计充满学术理想，也为有志于成为世界一流名校的大学树立了一座看得见摸得着的价值标杆：<strong>卓越、开放、自治、共享</strong>。</p>
<p>中国地图 &lt;worldmap.harvard.edu/chinamap&gt; 是其中一个子站，已经上线多个数据层，包括社会/人口、经济、交通、能源、环境/气候、公共卫生，甚至历史地图。比如下面的视图，就是细化到县级的人口密度热力图，默认叠加在OpenStreetMap底图上，效果非常棒。</p>
<!-- {% raw %} -->
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/wmap_harvard.png"/><figcaption>
            <h4>图 | 哈佛中国地图</h4>
        </figcaption>
</figure>
<!-- {% endraw %} -->
<p>让我特别感兴趣的是历史地图部分。上面赫然列着北宋、明、清的进士散点图和热力图。当把它们和当今人口密度热力图叠加显示，我们会惊讶地发现过去一千年来盛产进士的地方，几乎严丝合缝地对应着今天中国人口最稠密的地区。进士分布只能指示那个时代的财富分布。但把千年以来的进士之乡叠加起来（如同叠加起无数个财富变迁的历史断面），就能看到这些财富分布的残影。而古今之间的这种辉映，说明今天的人们依然在从宋以降的这种“地气”大格局中受惠。</p>
<p>右键这三个进士数据层，选择“Share Layer”，就能看到一个分享页面。除了视图本身，还有参考数据集的链接，可以导出多种格式。我们导一个Excel出来。Excel的名称是CBDB_exams_NSong_WGS84_kto.xls。</p>
<!-- {% raw %} -->
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/cbdb_data.png"/><figcaption>
            <h4>图 | CBDB科举数据集</h4>
        </figcaption>
</figure>
<!-- {% endraw %} -->
<p>这就十分厉害了：</p>
<ol>
<li>CBDB，是大名鼎鼎的哈佛中国历代人物传记数据库(China Biographical Database)。这个图层的基础，来自CBDB，可靠性就有保障了。这个数据库内容非常丰富，后面还会用到；</li>
<li>WGS84，说明坐标系用的是WGS-84坐标系，所以只要利用基于WGS-84的GIS工具，就不需要针对GCJ-02或BD-09做逆偏置了。</li>
</ol>
<h2 id="进士最大来源地">进士最大来源地？</h2>
<p>先把北宋、明、清三个进士数据集都载入R。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">readr</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">nsong.js</span> <span class="o">&lt;-</span> <span class="nf">read_csv</span><span class="p">(</span><span class="s">&#34;下载/CBDB_exams_NSong_WGS84_kto.csv&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ming.js</span> <span class="o">&lt;-</span> <span class="nf">read_csv</span><span class="p">(</span><span class="s">&#34;下载/CBDB_exams_Ming_WGS84_MbJ.csv&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">qing.js</span> <span class="o">&lt;-</span> <span class="nf">read_csv</span><span class="p">(</span><span class="s">&#34;下载/CBDB_exams_Qing_WGS84_GWU.csv&#34;</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>简单看一下哪个地方来的进士最多。</p>
<h3 id="北宋">北宋</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">sort</span><span class="p">(</span><span class="nf">table</span><span class="p">(</span><span class="n">nsong.js</span><span class="o">$</span><span class="n">AddrChn</span><span class="p">),</span> <span class="n">decreasing</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><table>
<thead>
<tr>
<th style="text-align:left">序号</th>
<th style="text-align:left">来源地</th>
<th style="text-align:right">人数</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">1</td>
<td style="text-align:left">莆田</td>
<td style="text-align:right">194</td>
</tr>
<tr>
<td style="text-align:left">2</td>
<td style="text-align:left">吳縣</td>
<td style="text-align:right">121</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">閩縣</td>
<td style="text-align:right">94</td>
</tr>
<tr>
<td style="text-align:left">4</td>
<td style="text-align:left">晉江</td>
<td style="text-align:right">88</td>
</tr>
<tr>
<td style="text-align:left">5</td>
<td style="text-align:left">仙遊</td>
<td style="text-align:right">69</td>
</tr>
<tr>
<td style="text-align:left">6</td>
<td style="text-align:left">侯官</td>
<td style="text-align:right">62</td>
</tr>
<tr>
<td style="text-align:left">7</td>
<td style="text-align:left">開封</td>
<td style="text-align:right">60</td>
</tr>
<tr>
<td style="text-align:left">8</td>
<td style="text-align:left">眉山</td>
<td style="text-align:right">60</td>
</tr>
<tr>
<td style="text-align:left">9</td>
<td style="text-align:left">武進</td>
<td style="text-align:right">51</td>
</tr>
<tr>
<td style="text-align:left">10</td>
<td style="text-align:left">德興</td>
<td style="text-align:right">50</td>
</tr>
</tbody>
</table>
<p>大胡建第一名！这还不算，胡建里的第一名是莆田！</p>
<h3 id="明朝">明朝</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">sort</span><span class="p">(</span><span class="nf">table</span><span class="p">(</span><span class="n">ming.js</span><span class="o">$</span><span class="n">AddrChn</span><span class="p">),</span> <span class="n">decreasing</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><table>
<thead>
<tr>
<th style="text-align:left">序号</th>
<th style="text-align:left">来源地</th>
<th style="text-align:right">人数</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">1</td>
<td style="text-align:left">莆田</td>
<td style="text-align:right">109</td>
</tr>
<tr>
<td style="text-align:left">2</td>
<td style="text-align:left">鄞縣</td>
<td style="text-align:right">40</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">華亭</td>
<td style="text-align:right">37</td>
</tr>
<tr>
<td style="text-align:left">4</td>
<td style="text-align:left">吉水</td>
<td style="text-align:right">33</td>
</tr>
<tr>
<td style="text-align:left">5</td>
<td style="text-align:left">慈溪</td>
<td style="text-align:right">28</td>
</tr>
<tr>
<td style="text-align:left">6</td>
<td style="text-align:left">安福</td>
<td style="text-align:right">25</td>
</tr>
<tr>
<td style="text-align:left">7</td>
<td style="text-align:left">平湖</td>
<td style="text-align:right">22</td>
</tr>
<tr>
<td style="text-align:left">8</td>
<td style="text-align:left">吳縣</td>
<td style="text-align:right">22</td>
</tr>
<tr>
<td style="text-align:left">9</td>
<td style="text-align:left">餘姚</td>
<td style="text-align:right">21</td>
</tr>
<tr>
<td style="text-align:left">10</td>
<td style="text-align:left">常熟</td>
<td style="text-align:right">20</td>
</tr>
</tbody>
</table>
<p>到明朝，浙江赶上来了。但莆田还是第一名，并且是等于2-4名总和的那种第一名！</p>
<h3 id="清朝">清朝</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">sort</span><span class="p">(</span><span class="nf">table</span><span class="p">(</span><span class="n">qing.js</span><span class="o">$</span><span class="n">AddrChn</span><span class="p">),</span> <span class="n">decreasing</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><table>
<thead>
<tr>
<th style="text-align:left">序号</th>
<th style="text-align:left">来源地</th>
<th style="text-align:right">人数</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">1</td>
<td style="text-align:left">錢塘</td>
<td style="text-align:right">93</td>
</tr>
<tr>
<td style="text-align:left">2</td>
<td style="text-align:left">仁和</td>
<td style="text-align:right">91</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">大興</td>
<td style="text-align:right">60</td>
</tr>
<tr>
<td style="text-align:left">4</td>
<td style="text-align:left">吳縣</td>
<td style="text-align:right">39</td>
</tr>
<tr>
<td style="text-align:left">5</td>
<td style="text-align:left">長洲</td>
<td style="text-align:right">39</td>
</tr>
<tr>
<td style="text-align:left">6</td>
<td style="text-align:left">侯官</td>
<td style="text-align:right">38</td>
</tr>
<tr>
<td style="text-align:left">7</td>
<td style="text-align:left">桐城</td>
<td style="text-align:right">37</td>
</tr>
<tr>
<td style="text-align:left">8</td>
<td style="text-align:left">歙縣</td>
<td style="text-align:right">36</td>
</tr>
<tr>
<td style="text-align:left">9</td>
<td style="text-align:left">武進</td>
<td style="text-align:right">36</td>
</tr>
<tr>
<td style="text-align:left">10</td>
<td style="text-align:left">歸安</td>
<td style="text-align:right">35</td>
</tr>
</tbody>
</table>
<p>到清朝，浙江兴盛依旧，而莆田却掉队看不见了。
事实上，莆田在科举史上的衰落是非常惊人的。我们可以把图画出来。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span><span class="lnt">9
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">dplyr</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">ggplot2</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">ggthemes</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">jinshi</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="s">&#34;bind_rows&#34;</span><span class="p">,</span> <span class="nf">list</span><span class="p">(</span><span class="n">nsong.js</span><span class="p">,</span> <span class="n">ming.js</span><span class="p">,</span> <span class="n">qing.js</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="n">jinshi.putian</span> <span class="o">&lt;-</span> <span class="n">jinshi[jinshi</span><span class="o">$</span><span class="n">AddrChn</span><span class="o">==</span><span class="s">&#39;莆田&#39;</span><span class="p">,</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"><span class="n">jinshi.putian</span> <span class="o">&lt;-</span> <span class="nf">dcast</span><span class="p">(</span><span class="n">jinshi.putian</span><span class="p">,</span> <span class="n">EntryYear</span><span class="o">~</span><span class="n">.,</span> <span class="n">length</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">jinshi.putian</span><span class="o">$</span><span class="n">EntryYear</span> <span class="o">&lt;-</span> <span class="nf">as.integer</span><span class="p">(</span><span class="n">jinshi.putian</span><span class="o">$</span><span class="n">EntryYear</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">ggplot</span><span class="p">()</span> <span class="o">+</span> <span class="nf">geom_bar</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">EntryYear</span><span class="p">,</span> <span class="n">.)</span><span class="p">,</span> <span class="n">stat</span><span class="o">=</span><span class="s">&#39;identity&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">jinshi.putian</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">theme_hc</span><span class="p">()</span> <span class="o">+</span> <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;莆田进士数变迁&#34;</span><span class="p">)</span> <span class="o">+</span> <span class="nf">xlab</span><span class="p">(</span><span class="s">&#34;年份&#34;</span><span class="p">)</span> <span class="o">+</span> <span class="nf">ylab</span><span class="p">(</span><span class="s">&#34;人数&#34;</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><!-- {% raw %} -->
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/PutianJinshi.png"/><figcaption>
            <h4>图 | 莆田进士人数的变迁</h4>
        </figcaption>
</figure>
<!-- {% endraw %} -->
<p>南宋、元代没有数据，所以是空白。明代自1560年代后，进士数就突然非常稀疏。原因很简单：这一年倭寇攻陷莆田并屠城。从此莆田文脉衰颓，再也没有复兴。</p>
<p>即使在500年前就已弃赛，把北宋、明、清三代的进士数合起来统计，莆田还是遥遥领先。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">sort</span><span class="p">(</span><span class="nf">table</span><span class="p">(</span><span class="n">jinshi</span><span class="o">$</span><span class="n">AddrChn</span><span class="p">),</span> <span class="n">decreasing</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><table>
<thead>
<tr>
<th style="text-align:left">序号</th>
<th style="text-align:left">来源地</th>
<th style="text-align:right">人数</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">1</td>
<td style="text-align:left">莆田</td>
<td style="text-align:right">311</td>
</tr>
<tr>
<td style="text-align:left">2</td>
<td style="text-align:left">吳縣</td>
<td style="text-align:right">182</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">錢塘</td>
<td style="text-align:right">157</td>
</tr>
<tr>
<td style="text-align:left">4</td>
<td style="text-align:left">閩縣</td>
<td style="text-align:right">137</td>
</tr>
<tr>
<td style="text-align:left">5</td>
<td style="text-align:left">晉江</td>
<td style="text-align:right">118</td>
</tr>
<tr>
<td style="text-align:left">6</td>
<td style="text-align:left">鄞縣</td>
<td style="text-align:right">108</td>
</tr>
<tr>
<td style="text-align:left">7</td>
<td style="text-align:left">侯官</td>
<td style="text-align:right">107</td>
</tr>
<tr>
<td style="text-align:left">8</td>
<td style="text-align:left">武進</td>
<td style="text-align:right">103</td>
</tr>
<tr>
<td style="text-align:left">9</td>
<td style="text-align:left">仁和</td>
<td style="text-align:right">99</td>
</tr>
<tr>
<td style="text-align:left">10</td>
<td style="text-align:left">歸安</td>
<td style="text-align:right">72</td>
</tr>
</tbody>
</table>
<p>所以，以后碰到“南蛮、南蛮”的地图炮可以硬怼——过于可笑了，以千年尺度来衡量，进士生源地的前十名都是南蛮。</p>
<h2 id="地理可视化">地理可视化</h2>
<p>接下来，我要把这些信息用ggplot2可视化到地图上，需要采集很多额外的GIS数据。</p>
<h3 id="当代疆域">当代疆域</h3>
<p>当代疆域作为底图，需要拿国/省边界数据。在R中，<code>mapdata</code>配合<code>maps</code>可以取到国界数据，但太老了（重庆都没有）。反正只是示意，精度要求不那么高，我们可以到开放数据平台Diva-GIS.org去找数据。</p>
<!-- {% raw %} -->
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/divagis.png"/><figcaption>
            <h4>图 | Diva-GIS网站</h4>
        </figcaption>
</figure>
<!-- {% endraw %} -->
<p>需要分别下载CHN和TWN的地图数据（香港HKG和澳门MAC就不去下载了，反正都很小，不影响主要效果）。把CHN的Level1和TWN的Level0数据拼合起来，就大致妥了。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span><span class="lnt">9
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">cn.mapdata</span> <span class="o">&lt;-</span> <span class="nf">readOGR</span><span class="p">(</span><span class="s">&#34;下载/Regime_Bou/CHN_adm1.shp&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">tw.mapdata</span> <span class="o">&lt;-</span> <span class="nf">readOGR</span><span class="p">(</span><span class="s">&#34;下载/Regime_Bou/TWN_adm0.shp&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">p.chn</span> <span class="o">&lt;-</span> <span class="nf">ggplot</span><span class="p">()</span> <span class="o">+</span> <span class="nf">geom_polygon</span><span class="p">(</span>
</span></span><span class="line"><span class="cl">    <span class="nf">aes</span><span class="p">(</span><span class="n">long</span><span class="p">,</span> <span class="n">lat</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">group</span><span class="p">),</span> <span class="n">data</span><span class="o">=</span><span class="n">cn.mapdata</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="n">fill</span><span class="o">=</span><span class="s">&#39;gray97&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s">&#39;gray&#39;</span><span class="p">,</span> <span class="n">linetype</span><span class="o">=</span><span class="m">2</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="m">0.2</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">geom_polygon</span><span class="p">(</span>
</span></span><span class="line"><span class="cl">        <span class="nf">aes</span><span class="p">(</span><span class="n">long</span><span class="p">,</span> <span class="n">lat</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">group</span><span class="p">),</span> <span class="n">data</span><span class="o">=</span><span class="n">tw.mapdata</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">        <span class="n">fill</span><span class="o">=</span><span class="s">&#39;gray97&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s">&#39;gray&#39;</span><span class="p">,</span> <span class="n">linetype</span><span class="o">=</span><span class="m">2</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="m">0.2</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">theme_minimal</span><span class="p">()</span> <span class="o">+</span> <span class="nf">coord_map</span><span class="p">()</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>这个p.chn对象后面可以反复复用。</p>
<!-- {% raw %} -->
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/ChnMap.png"/><figcaption>
            <h4>图 | 中国地图底图</h4>
        </figcaption>
</figure>
<!-- {% endraw %} -->
<h3 id="古代疆域">古代疆域</h3>
<p>古代疆域就不太容易下载到现成的了，好在我们也有开源平台可以用：发现中国（webdog.cn）。这是一个基于WebGIS技术的公益网站，用户可以自己创建地图，最简单的玩法是衬一张历史地图底图，然后创建图层描点。地图数据以KML格式存储，可以导出来。KML本质是一种XML标记语言，Google地图就使用它。</p>
<!-- {% raw %} -->
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/webdog.png"/><figcaption>
            <h4>图 | 发现中国（Webdog）</h4>
        </figcaption>
</figure>
<!-- {% endraw %} -->
<p>我们可以登进去，复制其他用户创建好的地图，然后导出来。导出的KMZ是KML的压缩包，Zip解压即可。</p>
<p>创建两个工作函数，把KML转化为list，然后从list中提取出坐标数据，并清理转化为数据框。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">get_xml_list</span> <span class="o">&lt;-</span> <span class="nf">function</span><span class="p">(</span><span class="n">xml</span><span class="p">){</span>
</span></span><span class="line"><span class="cl">    <span class="nf">library</span><span class="p">(</span><span class="n">XML</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="nf">xmlToList</span><span class="p">(</span><span class="nf">xmlParse</span><span class="p">(</span><span class="n">xml</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="n">get_coord_df</span> <span class="o">&lt;-</span> <span class="nf">function</span><span class="p">(</span><span class="n">lst</span><span class="p">,</span> <span class="n">split</span><span class="o">=</span><span class="s">&#34;[ ,]&#34;</span><span class="p">,</span> <span class="n">id</span><span class="o">=</span><span class="m">1</span><span class="p">){</span>
</span></span><span class="line"><span class="cl">    <span class="n">staging</span> <span class="o">&lt;-</span> <span class="nf">strsplit</span><span class="p">(</span><span class="n">lst</span><span class="p">,</span> <span class="n">split</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="n">out</span> <span class="o">&lt;-</span> <span class="nf">data.frame</span><span class="p">(</span><span class="nf">matrix</span><span class="p">(</span>
</span></span><span class="line"><span class="cl">        <span class="nf">as.numeric</span><span class="p">(</span><span class="nf">unlist</span><span class="p">(</span><span class="n">staging</span><span class="p">)),</span> <span class="n">byrow</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">,</span> <span class="n">ncol</span><span class="o">=</span><span class="m">2</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">    <span class="nf">names</span><span class="p">(</span><span class="n">out</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;long&#34;</span><span class="p">,</span> <span class="s">&#34;lat&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="n">out</span><span class="o">$</span><span class="n">id</span> <span class="o">&lt;-</span> <span class="n">id</span>
</span></span><span class="line"><span class="cl">    <span class="nf">return</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>由于每张地图都有多个边界节点（大陆、海南、台湾），所以要串成list提出来。这就需要利用mapply了：提取、命名map_id、合并数据框，一气呵成。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span><span class="lnt">18
</span><span class="lnt">19
</span><span class="lnt">20
</span><span class="lnt">21
</span><span class="lnt">22
</span><span class="lnt">23
</span><span class="lnt">24
</span><span class="lnt">25
</span><span class="lnt">26
</span><span class="lnt">27
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># 北宋</span>
</span></span><span class="line"><span class="cl"><span class="n">nsong.xml</span> <span class="o">&lt;-</span> <span class="nf">get_xml_list</span><span class="p">(</span><span class="s">&#34;~/下载/northSong.kml&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">nsong.bou</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span>
</span></span><span class="line"><span class="cl">    <span class="n">nsong.xml[[1]][[3]][[3]]</span><span class="o">$</span><span class="n">Polygon</span><span class="o">$</span><span class="n">outerBoundaryIs</span><span class="o">$</span><span class="n">LinearRing</span><span class="o">$</span><span class="n">coordinates</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="n">nsong.xml[[1]][[3]][[4]]</span><span class="o">$</span><span class="n">Polygon</span><span class="o">$</span><span class="n">outerBoundaryIs</span><span class="o">$</span><span class="n">LinearRing</span><span class="o">$</span><span class="n">coordinates</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">nsong.bou</span> <span class="o">&lt;-</span> <span class="nf">mapply</span><span class="p">(</span><span class="n">get_coord_df</span><span class="p">,</span> <span class="n">nsong.bou</span><span class="p">,</span> <span class="n">id</span><span class="o">=</span><span class="m">1</span><span class="o">:</span><span class="m">2</span><span class="p">,</span> <span class="n">SIMPLIFY</span><span class="o">=</span><span class="kc">FALSE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">names</span><span class="p">(</span><span class="n">nsong.bou</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="m">1</span><span class="o">:</span><span class="m">2</span>
</span></span><span class="line"><span class="cl"><span class="n">nsong.bou</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="s">&#39;rbind&#39;</span><span class="p">,</span> <span class="n">nsong.bou</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 明朝</span>
</span></span><span class="line"><span class="cl"><span class="n">ming.xml</span> <span class="o">&lt;-</span> <span class="nf">get_xml_list</span><span class="p">(</span><span class="s">&#34;~/下载/ming.kml&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ming.bou</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span>
</span></span><span class="line"><span class="cl">    <span class="n">ming.xml[[1]][[3]][[3]]</span><span class="o">$</span><span class="n">outerBoundaryIs</span><span class="o">$</span><span class="n">LinearRing</span><span class="o">$</span><span class="n">coordinates</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="n">ming.xml[[1]][[4]][[3]]</span><span class="o">$</span><span class="n">outerBoundaryIs</span><span class="o">$</span><span class="n">LinearRing</span><span class="o">$</span><span class="n">coordinates</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="n">ming.xml[[1]][[5]][[3]]</span><span class="o">$</span><span class="n">outerBoundaryIs</span><span class="o">$</span><span class="n">LinearRing</span><span class="o">$</span><span class="n">coordinates</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ming.bou</span> <span class="o">&lt;-</span> <span class="nf">mapply</span><span class="p">(</span><span class="n">get_coord_df</span><span class="p">,</span> <span class="n">ming.bou</span><span class="p">,</span> <span class="n">id</span><span class="o">=</span><span class="m">1</span><span class="o">:</span><span class="m">3</span><span class="p">,</span> <span class="n">SIMPLIFY</span><span class="o">=</span><span class="kc">FALSE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">names</span><span class="p">(</span><span class="n">ming.bou</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="m">1</span><span class="o">:</span><span class="m">3</span>
</span></span><span class="line"><span class="cl"><span class="n">ming.bou</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="s">&#39;rbind&#39;</span><span class="p">,</span> <span class="n">ming.bou</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 清朝</span>
</span></span><span class="line"><span class="cl"><span class="n">qing.xml</span> <span class="o">&lt;-</span> <span class="nf">get_xml_list</span><span class="p">(</span><span class="s">&#34;~/下载/qing.kml&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">qing.bou</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span>
</span></span><span class="line"><span class="cl">    <span class="n">qing.xml[[1]][[3]][[3]]</span><span class="o">$</span><span class="n">outerBoundaryIs</span><span class="o">$</span><span class="n">LinearRing</span><span class="o">$</span><span class="n">coordinates</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="n">qing.xml[[1]][[4]][[3]]</span><span class="o">$</span><span class="n">outerBoundaryIs</span><span class="o">$</span><span class="n">LinearRing</span><span class="o">$</span><span class="n">coordinates</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="n">qing.xml[[1]][[5]][[3]]</span><span class="o">$</span><span class="n">outerBoundaryIs</span><span class="o">$</span><span class="n">LinearRing</span><span class="o">$</span><span class="n">coordinates</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="n">qing.xml[[1]][[6]][[3]]</span><span class="o">$</span><span class="n">outerBoundaryIs</span><span class="o">$</span><span class="n">LinearRing</span><span class="o">$</span><span class="n">coordinates</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">qing.bou</span> <span class="o">&lt;-</span> <span class="nf">mapply</span><span class="p">(</span><span class="n">get_coord_df</span><span class="p">,</span> <span class="n">qing.bou</span><span class="p">,</span> <span class="n">id</span><span class="o">=</span><span class="m">1</span><span class="o">:</span><span class="m">4</span><span class="p">,</span> <span class="n">SIMPLIFY</span><span class="o">=</span><span class="kc">FALSE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">names</span><span class="p">(</span><span class="n">qing.bou</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="m">1</span><span class="o">:</span><span class="m">4</span>
</span></span><span class="line"><span class="cl"><span class="n">qing.bou</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="s">&#39;rbind&#39;</span><span class="p">,</span> <span class="n">qing.bou</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>宋、明火德，咱涂个红色。清没有官宣自己什么德，但坊间一般认为丫是水德，咱给涂个黑色。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span><span class="lnt">9
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">p.song</span> <span class="o">&lt;-</span> <span class="n">p.chn</span> <span class="o">+</span> <span class="nf">geom_polygon</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">long</span><span class="p">,</span> <span class="n">lat</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">id</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">	<span class="n">data</span><span class="o">=</span><span class="n">nsong.bou</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="s">&#34;red&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.1</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;北宋疆域&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">p.ming</span> <span class="o">&lt;-</span> <span class="n">p.chn</span> <span class="o">+</span> <span class="nf">geom_polygon</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">long</span><span class="p">,</span> <span class="n">lat</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">id</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">	<span class="n">data</span><span class="o">=</span><span class="n">ming.bou</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="s">&#34;red&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.1</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;明朝疆域&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">p.qing</span> <span class="o">&lt;-</span> <span class="n">p.chn</span> <span class="o">+</span> <span class="nf">geom_polygon</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">long</span><span class="p">,</span> <span class="n">lat</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">id</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">	<span class="n">data</span><span class="o">=</span><span class="n">qing.bou</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="s">&#34;black&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.1</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;清朝疆域&#34;</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><!-- {% raw %} -->
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/NSongMap.png"/><figcaption>
            <h4>图 | 北宋疆域示意图</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/MingMap.png"/><figcaption>
            <h4>图 | 明朝疆域示意图</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/QingMap.png"/><figcaption>
            <h4>图 | 清朝疆域示意图</h4>
        </figcaption>
</figure>
<!-- {% endraw %} -->
<p>完美。</p>
<h3 id="进士来源地">进士来源地</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">p.song</span> <span class="o">+</span> <span class="nf">geom_point</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">x_coord</span><span class="p">,</span> <span class="n">y_coord</span><span class="p">),</span> <span class="n">data</span><span class="o">=</span><span class="n">nsong.js</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">	<span class="n">color</span><span class="o">=</span><span class="s">&#34;blue&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.2</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="m">0.5</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;北宋进士来源地&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">p.song</span> <span class="o">+</span> <span class="nf">stat_density_2d</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">x_coord</span><span class="p">,</span> <span class="n">y_coord</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="n">..level..</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">    <span class="n">data</span><span class="o">=</span><span class="n">nsong.js</span><span class="p">,</span> <span class="n">geom</span><span class="o">=</span><span class="s">&#34;polygon&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.5</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">scale_fill_gradient</span><span class="p">(</span><span class="n">low</span><span class="o">=</span><span class="s">&#34;cyan&#34;</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="s">&#34;darkblue&#34;</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;北宋进士来源地&#34;</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/NSongJinshi1.png"/><figcaption>
            <h4>图 | 北宋进士来源地散点图</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/NSongJinshi2.png"/><figcaption>
            <h4>图 | 北宋进士来源地热力图</h4>
        </figcaption>
</figure>
<p>北宋的进士来源地呈现江浙、福建双巨头，江西、四川、河南三极的格局。元祐新旧党争，旧党分为朔、洛、蜀，正好对应于河南、四川这两极，而司马光特别瞧不起闽、楚之人，正是进士热图上特别炽热的福建、江西。之所以敌意这么重，就是因为这几个地方科举太厉害了，却聊不到一块儿去。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">p.ming</span> <span class="o">+</span> <span class="nf">geom_point</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">x_coord</span><span class="p">,</span> <span class="n">y_coord</span><span class="p">),</span> <span class="n">data</span><span class="o">=</span><span class="n">ming.js</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">	<span class="n">color</span><span class="o">=</span><span class="s">&#34;blue&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.2</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="m">0.5</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;明朝进士来源地&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">p.ming</span> <span class="o">+</span> <span class="nf">stat_density_2d</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">x_coord</span><span class="p">,</span> <span class="n">y_coord</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="n">..level..</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">	<span class="n">data</span><span class="o">=</span><span class="n">ming.js</span><span class="p">,</span> <span class="n">geom</span><span class="o">=</span><span class="s">&#34;polygon&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.5</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">scale_fill_gradient</span><span class="p">(</span><span class="n">low</span><span class="o">=</span><span class="s">&#34;cyan&#34;</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="s">&#34;darkblue&#34;</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;明朝进士来源地&#34;</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/MingJinshi1.png"/><figcaption>
            <h4>图 | 明代进士来源地散点图</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/MingJinshi2.png"/><figcaption>
            <h4>图 | 明代进士来源地热力图</h4>
        </figcaption>
</figure>
<p>到明代，双巨头格局不复存在，只剩下江浙一极独大，其余几个热点地区分别是北直隶、江西、福建、河南。四川从多极格局中完全消失，可见蒙元入侵影响之深远。天启中，东林党与阉党争权，前者恰好对应于江南单极，于是剩下几极（齐党、楚党、浙党）不得不寄身阉党羽翼下。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">p.qing</span> <span class="o">+</span> <span class="nf">geom_point</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">x_coord</span><span class="p">,</span> <span class="n">y_coord</span><span class="p">),</span> <span class="n">data</span><span class="o">=</span><span class="n">qing.js</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">	<span class="n">color</span><span class="o">=</span><span class="s">&#34;blue&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.2</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="m">0.5</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;清朝进士来源地&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">p.qing</span> <span class="o">+</span> <span class="nf">stat_density_2d</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">x_coord</span><span class="p">,</span> <span class="n">y_coord</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="n">..level..</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">	<span class="n">data</span><span class="o">=</span><span class="n">qing.js</span><span class="p">,</span> <span class="n">geom</span><span class="o">=</span><span class="s">&#34;polygon&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.5</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">scale_fill_gradient</span><span class="p">(</span><span class="n">low</span><span class="o">=</span><span class="s">&#34;cyan&#34;</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="s">&#34;darkblue&#34;</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;清朝进士来源地&#34;</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/QingJinshi1.png"/><figcaption>
            <h4>图 | 清代进士来源地散点图</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/QingJinshi2.png"/><figcaption>
            <h4>图 | 清代进士来源地热力图</h4>
        </figcaption>
</figure>
<p>清代继续沿袭江浙单极格局。福建进一步萎缩，而长江中下游的安徽、湖北、湖南、江西都呈现相当的强势，另一个强势的地区则是京畿的直隶、山东。</p>
<p>从进士热图来看：</p>
<ol>
<li>长江中下游的整体强势千年未减；</li>
<li>福建、四川逐渐褪色;</li>
<li>京畿总能额外占据一极，这一点，今天依然如故。</li>
</ol>
<p>把历代数据叠起来看，更加清晰。江浙赣闽文脉相连，而另一个特别明显的现象是淮河流域有一整片真空——这里不怎么出进士，相应地比较适合出皇帝和武将。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">p.chn</span> <span class="o">+</span> <span class="nf">geom_point</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">x_coord</span><span class="p">,</span> <span class="n">y_coord</span><span class="p">),</span> <span class="n">data</span><span class="o">=</span><span class="n">jinshi</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">	<span class="n">color</span><span class="o">=</span><span class="s">&#34;blue&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.2</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="m">0.5</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;北宋、明、清进士来源地&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">p.chn</span> <span class="o">+</span> <span class="nf">stat_density_2d</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">x_coord</span><span class="p">,</span> <span class="n">y_coord</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="n">..level..</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">	<span class="n">data</span><span class="o">=</span><span class="n">jinshi</span><span class="p">,</span> <span class="n">geom</span><span class="o">=</span><span class="s">&#34;polygon&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.5</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">scale_fill_gradient</span><span class="p">(</span><span class="n">low</span><span class="o">=</span><span class="s">&#34;cyan&#34;</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="s">&#34;darkblue&#34;</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;北宋、明、清进士来源地&#34;</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/SongMingQingJinshi1.png"/><figcaption>
            <h4>图 | 北宋、明、清进士来源地散点图</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/SongMingQingJinshi2.png"/><figcaption>
            <h4>图 | 北宋、明、清进士来源地热力图</h4>
        </figcaption>
</figure>
<h2 id="来源地的时间趋势">来源地的时间趋势</h2>
<p>上面这些图都是把历时因素剔除后看的叠影效应。然而，这些来源地有没有什么时间上的变化趋势呢？</p>
<p>进士数据集包含EntryYear和AddrChn，但地名颗粒太细（县级），有必要归集到一级行政区。这就需要拿辅助数据了。</p>
<h3 id="cbdb数据库">CBDB数据库</h3>
<p>CBDB数据库有两种离线版本：MS Access和SQLite。我用Linux，所以只能选后者。</p>
<!-- {% raw %} -->
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/harvard_cbdb.png"/><figcaption>
            <h4>图 | 哈佛CBDB数据库</h4>
        </figcaption>
</figure>
<!-- {% endraw %} -->
<p>下下来之后，用RSQLite来抽数据。我的用法不复杂，只要取出Addresses表就行。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">RSQLite</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">con</span> <span class="o">&lt;-</span> <span class="nf">dbConnect</span><span class="p">(</span><span class="nf">SQLite</span><span class="p">(),</span> <span class="s">&#34;下载/cbdb_sqlite.db&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">addr</span> <span class="o">&lt;-</span> <span class="nf">dbReadTable</span><span class="p">(</span><span class="n">con</span><span class="p">,</span> <span class="s">&#34;ADDRESSES&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">dbDisconnect</span><span class="p">(</span><span class="n">con</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>数据表里有一列c_name_chn，对应于最小细度的地名，之后有belongs2_name，belongs3_name等上级政区名。merge一下，就能取到一级政区名了。</p>
<p>构造一个函数<code>get_stat</code>，来构成某朝代的政区字典，merge进进士数据集，并统计出时间分布。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span><span class="lnt">18
</span><span class="lnt">19
</span><span class="lnt">20
</span><span class="lnt">21
</span><span class="lnt">22
</span><span class="lnt">23
</span><span class="lnt">24
</span><span class="lnt">25
</span><span class="lnt">26
</span><span class="lnt">27
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">get_stat</span> <span class="o">&lt;-</span> <span class="nf">function</span><span class="p">(</span><span class="n">addr</span><span class="p">,</span> <span class="n">jsdt</span><span class="p">,</span> <span class="n">dyn.name</span><span class="p">,</span> <span class="n">yr.begin</span><span class="p">,</span> <span class="n">yr.end</span><span class="p">){</span>
</span></span><span class="line"><span class="cl">	<span class="n">addr.dyn</span> <span class="o">&lt;-</span> <span class="n">addr[addr</span><span class="o">$</span><span class="n">belongs3_Name</span> <span class="o">==</span> <span class="n">dyn.name</span> <span class="o">|</span>
</span></span><span class="line"><span class="cl">					  <span class="n">addr</span><span class="o">$</span><span class="n">belongs4_Name</span> <span class="o">==</span> <span class="n">dyn.name</span> <span class="o">|</span>
</span></span><span class="line"><span class="cl">                      <span class="n">addr</span><span class="o">$</span><span class="n">belongs5_Name</span> <span class="o">==</span> <span class="n">dyn.name</span><span class="p">,</span><span class="n">]</span>
</span></span><span class="line"><span class="cl">	<span class="n">addr.dyn</span> <span class="o">&lt;-</span><span class="n">addr.dyn[</span><span class="o">!</span><span class="nf">is.na</span><span class="p">(</span><span class="n">addr.dyn</span><span class="o">$</span><span class="n">c_name_chn</span><span class="p">),</span><span class="n">]</span>
</span></span><span class="line"><span class="cl">	<span class="n">addr.dyn</span><span class="o">$</span><span class="n">Prov</span> <span class="o">&lt;-</span> <span class="n">addr.dyn</span><span class="o">$</span><span class="n">belongs2_Name</span>
</span></span><span class="line"><span class="cl">	<span class="n">i</span> <span class="o">&lt;-</span> <span class="nf">which</span><span class="p">(</span><span class="n">addr.dyn</span><span class="o">$</span><span class="n">belongs4_Name</span> <span class="o">==</span> <span class="n">dyn.name</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">	<span class="n">addr.dyn</span><span class="o">$</span><span class="n">Prov[i]</span> <span class="o">&lt;-</span> <span class="n">addr.dyn</span><span class="o">$</span><span class="n">belongs3_Name[i]</span>
</span></span><span class="line"><span class="cl">	<span class="n">i</span> <span class="o">&lt;-</span> <span class="nf">which</span><span class="p">(</span><span class="n">addr.dyn</span><span class="o">$</span><span class="n">belongs5_Name</span> <span class="o">==</span> <span class="n">dyn.name</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">	<span class="n">addr.dyn</span><span class="o">$</span><span class="n">Prov[i]</span> <span class="o">&lt;-</span> <span class="n">addr.dyn</span><span class="o">$</span><span class="n">belongs4_Name[i]</span>
</span></span><span class="line"><span class="cl">	<span class="n">addr.dyn</span> <span class="o">&lt;-</span> <span class="n">addr.dyn[</span><span class="o">!</span><span class="nf">duplicated</span><span class="p">(</span><span class="n">addr.dyn</span><span class="o">$</span><span class="n">c_name_chn</span><span class="p">),</span><span class="n">]</span>
</span></span><span class="line"><span class="cl">	<span class="n">js</span> <span class="o">&lt;-</span> <span class="nf">merge</span><span class="p">(</span><span class="n">jsdt</span><span class="p">,</span> <span class="n">addr.dyn[</span><span class="p">,</span><span class="nf">c</span><span class="p">(</span><span class="s">&#34;c_name_chn&#34;</span><span class="p">,</span> <span class="s">&#34;Prov&#34;</span><span class="p">)</span><span class="n">]</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">                <span class="n">by.x</span><span class="o">=</span><span class="s">&#34;AddrChn&#34;</span><span class="p">,</span> <span class="n">by.y</span><span class="o">=</span><span class="s">&#34;c_name_chn&#34;</span><span class="p">,</span> <span class="n">all.x</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">	<span class="n">js</span><span class="o">$</span><span class="n">Decade</span> <span class="o">&lt;-</span> <span class="nf">cut</span><span class="p">(</span><span class="nf">as.numeric</span><span class="p">(</span><span class="n">js</span><span class="o">$</span><span class="n">EntryYear</span><span class="p">),</span> <span class="nf">seq</span><span class="p">(</span><span class="n">yr.begin</span><span class="p">,</span> <span class="n">yr.end</span><span class="p">,</span> <span class="m">10</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">	<span class="n">js</span><span class="o">$</span><span class="n">Decade</span> <span class="o">&lt;-</span> <span class="nf">factor</span><span class="p">(</span><span class="n">js</span><span class="o">$</span><span class="n">Decade</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">		<span class="n">labels</span><span class="o">=</span><span class="nf">seq</span><span class="p">(</span><span class="n">yr.begin</span><span class="p">,</span> <span class="n">yr.end</span><span class="p">,</span> <span class="m">10</span><span class="p">)</span><span class="n">[1</span><span class="o">:</span><span class="nf">nlevels</span><span class="p">(</span><span class="n">nsong.js</span><span class="o">$</span><span class="n">Decade</span><span class="p">)</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">	<span class="n">stat1</span> <span class="o">&lt;-</span> <span class="nf">dcast</span><span class="p">(</span><span class="n">js</span><span class="p">,</span> <span class="n">Prov</span><span class="o">~</span><span class="n">.,</span> <span class="n">length</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">	<span class="n">stat1</span> <span class="o">&lt;-</span> <span class="n">stat1</span><span class="nf">[order</span><span class="p">(</span><span class="n">stat1</span><span class="o">$</span><span class="n">.,</span> <span class="n">decreasing</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">),</span><span class="n">]</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">	<span class="n">stat</span> <span class="o">&lt;-</span> <span class="nf">dcast</span><span class="p">(</span><span class="n">js</span><span class="p">,</span> <span class="n">Decade</span><span class="o">~</span><span class="n">Prov</span><span class="p">,</span> <span class="n">length</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">	<span class="n">stat</span> <span class="o">&lt;-</span> <span class="nf">melt</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">id</span><span class="o">=</span><span class="s">&#34;Decade&#34;</span><span class="p">,</span> <span class="n">stringsAsFactors</span><span class="o">=</span><span class="kc">FALSE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">	<span class="n">stat</span><span class="o">$</span><span class="n">Decade</span> <span class="o">&lt;-</span> <span class="nf">as.integer</span><span class="p">(</span><span class="nf">as.character</span><span class="p">(</span><span class="n">stat</span><span class="o">$</span><span class="n">Decade</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">	<span class="n">stat</span><span class="o">$</span><span class="n">variable</span> <span class="o">&lt;-</span> <span class="nf">factor</span><span class="p">(</span><span class="n">stat</span><span class="o">$</span><span class="n">variable</span><span class="p">,</span> <span class="n">levels</span><span class="o">=</span><span class="n">stat1</span><span class="o">$</span><span class="n">Prov</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">	<span class="n">stat</span> <span class="o">&lt;-</span> <span class="n">stat[</span><span class="o">!</span><span class="nf">is.na</span><span class="p">(</span><span class="n">stat</span><span class="o">$</span><span class="n">variable</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">stat</span><span class="o">$</span><span class="n">variable</span> <span class="o">!=</span> <span class="s">&#39;NA&#39;</span><span class="p">,</span><span class="n">]</span>
</span></span><span class="line"><span class="cl">	<span class="nf">return</span><span class="p">(</span><span class="n">stat</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>这样做未必精确。有些地名匹配不到，有些一级行政区的名称有歧称。有时间还可以进一步审查，没时间就粗粗看个大概。</p>
<h3 id="北宋-1">北宋</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">palcols</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="nf">hc_pal</span><span class="p">()(</span><span class="m">10</span><span class="p">),</span> <span class="nf">tableau_color_pal</span><span class="p">()(</span><span class="m">10</span><span class="p">),</span> <span class="nf">wsj_pal</span><span class="p">()(</span><span class="m">6</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">		  <span class="nf">canva_pal</span><span class="p">()(</span><span class="m">4</span><span class="p">),</span> <span class="nf">economist_pal</span><span class="p">()(</span><span class="m">10</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="n">nsong.stat</span> <span class="o">&lt;-</span> <span class="nf">get_stat</span><span class="p">(</span><span class="n">addr</span><span class="p">,</span> <span class="n">nsong.js</span><span class="p">,</span> <span class="s">&#34;宋朝&#34;</span><span class="p">,</span> <span class="m">960</span><span class="p">,</span> <span class="m">1130</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">cols</span> <span class="o">&lt;-</span> <span class="n">palcols</span><span class="nf">[</span><span class="p">(</span><span class="m">1</span><span class="o">:</span><span class="nf">nlevels</span><span class="p">(</span><span class="n">nsong.stat</span><span class="o">$</span><span class="n">variable</span><span class="p">))</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"><span class="nf">names</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">levels</span><span class="p">(</span><span class="n">nsong.stat</span><span class="o">$</span><span class="n">variable</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">ggplot</span><span class="p">(</span><span class="n">nsong.stat</span><span class="p">,</span> <span class="nf">aes</span><span class="p">(</span><span class="n">Decade</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="n">variable</span><span class="p">))</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">geom_area</span><span class="p">(</span><span class="n">stat</span><span class="o">=</span><span class="s">&#34;identity&#34;</span><span class="p">,</span> <span class="n">position</span><span class="o">=</span><span class="s">&#34;fill&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.75</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">scale_fill_manual</span><span class="p">(</span><span class="n">values</span><span class="o">=</span><span class="n">cols</span><span class="p">)</span> <span class="o">+</span> <span class="nf">theme_minimal</span><span class="p">()</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">scale_y_continuous</span><span class="p">(</span><span class="n">labels</span><span class="o">=</span><span class="n">scales</span><span class="o">::</span><span class="n">percent</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">xlab</span><span class="p">(</span><span class="s">&#34;年份&#34;</span><span class="p">)</span> <span class="o">+</span> <span class="nf">ylab</span><span class="p">(</span><span class="s">&#34;比重&#34;</span><span class="p">)</span> <span class="o">+</span> <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;北宋进士来源地比重变迁&#34;</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">theme</span><span class="p">(</span><span class="n">legend.position</span><span class="o">=</span><span class="s">&#34;bottom&#34;</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/NSongJinshiProp1.png"/><figcaption>
            <h4>图 | 北宋进士来源地比重变化</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/NSongJinshiProp2.png"/><figcaption>
            <h4>图 | 北宋进士来源地变化</h4>
        </figcaption>
</figure>
<p>宋初主要仍从后周控制区取士，之后京畿路和河北东路等北方地区比重急剧下跌，而福建路、两浙西、两浙东路等地进士比重不断攀升。这是北宋时地气南倾的明显表现。</p>
<h3 id="明朝-1">明朝</h3>
<p>明朝的情况比较特别，一级行政区会同时出现布政司、巡抚等并列。需要额外归并一下。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">ming.stat</span> <span class="o">&lt;-</span> <span class="nf">get_stat</span><span class="p">(</span><span class="n">addr</span><span class="p">,</span> <span class="n">ming.js</span><span class="p">,</span> <span class="s">&#34;明朝&#34;</span><span class="p">,</span> <span class="m">1360</span><span class="p">,</span> <span class="m">1650</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ming.stat</span><span class="o">$</span><span class="n">variable</span> <span class="o">&lt;-</span> <span class="nf">gsub</span><span class="p">(</span><span class="s">&#34;(^.+)(布政司|巡撫|總督|留守司)$&#34;</span><span class="p">,</span> <span class="s">&#34;\\1&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">							<span class="n">ming.stat</span><span class="o">$</span><span class="n">variable</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ming.stat</span> <span class="o">&lt;-</span> <span class="nf">dcast</span><span class="p">(</span><span class="n">ming.stat</span><span class="p">,</span> <span class="n">Decade</span> <span class="o">~</span> <span class="n">variable</span><span class="p">,</span> <span class="n">sum</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ming.stat</span><span class="o">$</span><span class="n">Decade</span> <span class="o">&lt;-</span> <span class="nf">as.integer</span><span class="p">(</span><span class="n">ming.stat</span><span class="o">$</span><span class="n">Decade</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">cols</span> <span class="o">&lt;-</span> <span class="n">palcols</span><span class="nf">[</span><span class="p">(</span><span class="m">1</span><span class="o">:</span><span class="nf">nlevels</span><span class="p">(</span><span class="n">ming.stat</span><span class="o">$</span><span class="n">variable</span><span class="p">))</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"><span class="nf">names</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">levels</span><span class="p">(</span><span class="n">ming.stat</span><span class="o">$</span><span class="n">variable</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">ggplot</span><span class="p">(</span><span class="n">ming.stat</span><span class="p">,</span> <span class="nf">aes</span><span class="p">(</span><span class="n">Decade</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="n">variable</span><span class="p">))</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">geom_area</span><span class="p">(</span><span class="n">stat</span><span class="o">=</span><span class="s">&#34;identity&#34;</span><span class="p">,</span> <span class="n">position</span><span class="o">=</span><span class="s">&#34;fill&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.75</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">scale_fill_manual</span><span class="p">(</span><span class="n">values</span><span class="o">=</span><span class="n">cols</span><span class="p">)</span> <span class="o">+</span> <span class="nf">theme_minimal</span><span class="p">()</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">scale_y_continuous</span><span class="p">(</span><span class="n">labels</span><span class="o">=</span><span class="n">scales</span><span class="o">::</span><span class="n">percent</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">xlab</span><span class="p">(</span><span class="s">&#34;年份&#34;</span><span class="p">)</span> <span class="o">+</span> <span class="nf">ylab</span><span class="p">(</span><span class="s">&#34;比重&#34;</span><span class="p">)</span> <span class="o">+</span> <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;明朝进士来源地比重变迁&#34;</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">theme</span><span class="p">(</span><span class="n">legend.position</span><span class="o">=</span><span class="s">&#34;bottom&#34;</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/MingJinshiProp1.png"/><figcaption>
            <h4>图 | 明代进士来源地比重变化</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/MingJinshiProp2.png"/><figcaption>
            <h4>图 | 明代进士来源地变化</h4>
        </figcaption>
</figure>
<p>明代江西进士的比重一直在下降，而浙江、中都留守司（大体包括江苏和安徽）的比重明显升高。来自中都留守司辖区的进士比重在隆庆年间达到高峰，之后逐步下降。神宗后，来自山东、京师等北方地区的进士比重升高了。这也就是后来东林和阉党党争的人事基础。</p>
<h3 id="清朝-1">清朝</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span><span class="lnt">9
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">qing.stat</span> <span class="o">&lt;-</span> <span class="nf">get_stat</span><span class="p">(</span><span class="n">addr</span><span class="p">,</span> <span class="n">qing.js</span><span class="p">,</span> <span class="s">&#34;清朝&#34;</span><span class="p">,</span> <span class="m">1640</span><span class="p">,</span> <span class="m">1910</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">cols</span> <span class="o">&lt;-</span> <span class="n">palcols</span><span class="nf">[</span><span class="p">(</span><span class="m">1</span><span class="o">:</span><span class="nf">nlevels</span><span class="p">(</span><span class="n">qing.stat</span><span class="o">$</span><span class="n">variable</span><span class="p">))</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"><span class="nf">names</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">levels</span><span class="p">(</span><span class="n">qing.stat</span><span class="o">$</span><span class="n">variable</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">ggplot</span><span class="p">(</span><span class="n">qing.stat</span><span class="p">,</span> <span class="nf">aes</span><span class="p">(</span><span class="n">Decade</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="n">variable</span><span class="p">))</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">geom_area</span><span class="p">(</span><span class="n">stat</span><span class="o">=</span><span class="s">&#34;identity&#34;</span><span class="p">,</span> <span class="n">position</span><span class="o">=</span><span class="s">&#34;fill&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.75</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">scale_fill_manual</span><span class="p">(</span><span class="n">values</span><span class="o">=</span><span class="n">cols</span><span class="p">)</span> <span class="o">+</span> <span class="nf">theme_minimal</span><span class="p">()</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">scale_y_continuous</span><span class="p">(</span><span class="n">labels</span><span class="o">=</span><span class="n">scales</span><span class="o">::</span><span class="n">percent</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">xlab</span><span class="p">(</span><span class="s">&#34;年份&#34;</span><span class="p">)</span> <span class="o">+</span> <span class="nf">ylab</span><span class="p">(</span><span class="s">&#34;比重&#34;</span><span class="p">)</span> <span class="o">+</span> <span class="nf">ggtitle</span><span class="p">(</span><span class="s">&#34;清朝进士来源地比重变迁&#34;</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">    <span class="nf">theme</span><span class="p">(</span><span class="n">legend.position</span><span class="o">=</span><span class="s">&#34;bottom&#34;</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/QingJinshiProp1.png"/><figcaption>
            <h4>图 | 清代进士来源地比重变化</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/QingJinshiProp2.png"/><figcaption>
            <h4>图 | 清代进士来源地变化</h4>
        </figcaption>
</figure>
<p>清代前期江苏和浙江占了大头，中后期逐渐下降，而一个醒目的变化是湖南、广东比重的上升。这些人构成清后期变法维新的主力。</p>
<h2 id="姓氏">姓氏</h2>
<p>哪些姓氏的进士最多呢？</p>
<p>进士数据集有进士姓名。我们把这些姓名的首字提出来看一看（复姓就不管了。除非以后找一个语料库来细化）。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">stringr</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">fam.name</span> <span class="o">&lt;-</span> <span class="nf">str_sub</span><span class="p">(</span><span class="n">jinshi</span><span class="o">$</span><span class="n">NameChn</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span><span class="m">1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">sort</span><span class="p">(</span><span class="nf">table</span><span class="p">(</span><span class="n">fam.name</span><span class="p">),</span> <span class="n">decreasing</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>不知为什么，“張”写作了“瀳”，“陳”写作了“隇”。修正后，这个分布其实与整个大人群相差不大。</p>
<table>
<thead>
<tr>
<th style="text-align:center">1</th>
<th style="text-align:center">2</th>
<th style="text-align:center">3</th>
<th style="text-align:center">4</th>
<th style="text-align:center">5</th>
<th style="text-align:center">6</th>
<th style="text-align:center">7</th>
<th style="text-align:center">8</th>
<th style="text-align:center">9</th>
<th style="text-align:center">10</th>
<th style="text-align:center">11</th>
<th style="text-align:center">12</th>
<th style="text-align:center">13</th>
<th style="text-align:center">14</th>
<th style="text-align:center">15</th>
<th style="text-align:center">16</th>
<th style="text-align:center">17</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">王</td>
<td style="text-align:center">李</td>
<td style="text-align:center">瀳</td>
<td style="text-align:center">隇</td>
<td style="text-align:center">劉</td>
<td style="text-align:center">吳</td>
<td style="text-align:center">楊</td>
<td style="text-align:center">黃</td>
<td style="text-align:center">林</td>
<td style="text-align:center">周</td>
<td style="text-align:center">孫</td>
<td style="text-align:center">方</td>
<td style="text-align:center">朱</td>
<td style="text-align:center">徐</td>
<td style="text-align:center">酁</td>
<td style="text-align:center">胡</td>
<td style="text-align:center">許</td>
</tr>
<tr>
<td style="text-align:center">630</td>
<td style="text-align:center">477</td>
<td style="text-align:center">375</td>
<td style="text-align:center">373</td>
<td style="text-align:center">306</td>
<td style="text-align:center">242</td>
<td style="text-align:center">207</td>
<td style="text-align:center">196</td>
<td style="text-align:center">184</td>
<td style="text-align:center">182</td>
<td style="text-align:center">166</td>
<td style="text-align:center">164</td>
<td style="text-align:center">143</td>
<td style="text-align:center">138</td>
<td style="text-align:center">127</td>
<td style="text-align:center">124</td>
<td style="text-align:center">108</td>
</tr>
<tr>
<td style="text-align:center">趙</td>
<td style="text-align:center">沈</td>
<td style="text-align:center">陸</td>
<td style="text-align:center">何</td>
<td style="text-align:center">汪</td>
<td style="text-align:center">馮</td>
<td style="text-align:center">葉</td>
<td style="text-align:center">郭</td>
<td style="text-align:center">江</td>
<td style="text-align:center">錢</td>
<td style="text-align:center">程</td>
<td style="text-align:center">蔡</td>
<td style="text-align:center">董</td>
<td style="text-align:center">呂</td>
<td style="text-align:center">范</td>
<td style="text-align:center">曹</td>
<td style="text-align:center">彭</td>
</tr>
<tr>
<td style="text-align:center">99</td>
<td style="text-align:center">98</td>
<td style="text-align:center">95</td>
<td style="text-align:center">93</td>
<td style="text-align:center">85</td>
<td style="text-align:center">77</td>
<td style="text-align:center">73</td>
<td style="text-align:center">72</td>
<td style="text-align:center">71</td>
<td style="text-align:center">70</td>
<td style="text-align:center">69</td>
<td style="text-align:center">68</td>
<td style="text-align:center">68</td>
<td style="text-align:center">63</td>
<td style="text-align:center">62</td>
<td style="text-align:center">61</td>
<td style="text-align:center">60</td>
</tr>
<tr>
<td style="text-align:center">宋</td>
<td style="text-align:center">石</td>
<td style="text-align:center">謝</td>
<td style="text-align:center">曾</td>
<td style="text-align:center">章</td>
<td style="text-align:center">丁</td>
<td style="text-align:center">高</td>
<td style="text-align:center">梁</td>
<td style="text-align:center">馬</td>
<td style="text-align:center">唐</td>
<td style="text-align:center">邵</td>
<td style="text-align:center">余</td>
<td style="text-align:center">蔣</td>
<td style="text-align:center">姚</td>
<td style="text-align:center">傅</td>
<td style="text-align:center">潘</td>
<td style="text-align:center">史</td>
</tr>
<tr>
<td style="text-align:center">60</td>
<td style="text-align:center">59</td>
<td style="text-align:center">59</td>
<td style="text-align:center">58</td>
<td style="text-align:center">58</td>
<td style="text-align:center">57</td>
<td style="text-align:center">56</td>
<td style="text-align:center">55</td>
<td style="text-align:center">55</td>
<td style="text-align:center">55</td>
<td style="text-align:center">53</td>
<td style="text-align:center">49</td>
<td style="text-align:center">48</td>
<td style="text-align:center">48</td>
<td style="text-align:center">47</td>
<td style="text-align:center">47</td>
<td style="text-align:center">46</td>
</tr>
<tr>
<td style="text-align:center">戴</td>
<td style="text-align:center">蘇</td>
<td style="text-align:center">袁</td>
<td style="text-align:center">蕭</td>
<td style="text-align:center">韓</td>
<td style="text-align:center">毛</td>
<td style="text-align:center">魏</td>
<td style="text-align:center">金</td>
<td style="text-align:center">俞</td>
<td style="text-align:center">洪</td>
<td style="text-align:center">羅</td>
<td style="text-align:center">鄧</td>
<td style="text-align:center">田</td>
<td style="text-align:center">顧</td>
<td style="text-align:center">秦</td>
<td style="text-align:center">譚</td>
<td style="text-align:center">夏</td>
</tr>
<tr>
<td style="text-align:center">43</td>
<td style="text-align:center">42</td>
<td style="text-align:center">42</td>
<td style="text-align:center">40</td>
<td style="text-align:center">39</td>
<td style="text-align:center">39</td>
<td style="text-align:center">37</td>
<td style="text-align:center">36</td>
<td style="text-align:center">36</td>
<td style="text-align:center">35</td>
<td style="text-align:center">35</td>
<td style="text-align:center">34</td>
<td style="text-align:center">32</td>
<td style="text-align:center">31</td>
<td style="text-align:center">31</td>
<td style="text-align:center">31</td>
<td style="text-align:center">31</td>
</tr>
<tr>
<td style="text-align:center">盧</td>
<td style="text-align:center">秊</td>
<td style="text-align:center">葛</td>
<td style="text-align:center">黎</td>
<td style="text-align:center">翁</td>
<td style="text-align:center">熊</td>
<td style="text-align:center">薛</td>
<td style="text-align:center">孔</td>
<td style="text-align:center">廖</td>
<td style="text-align:center">歐</td>
<td style="text-align:center">陶</td>
<td style="text-align:center">詹</td>
<td style="text-align:center">杜</td>
<td style="text-align:center">侯</td>
<td style="text-align:center">阮</td>
<td style="text-align:center">嚴</td>
<td style="text-align:center">鄒</td>
</tr>
<tr>
<td style="text-align:center">28</td>
<td style="text-align:center">28</td>
<td style="text-align:center">27</td>
<td style="text-align:center">26</td>
<td style="text-align:center">26</td>
<td style="text-align:center">26</td>
<td style="text-align:center">25</td>
<td style="text-align:center">24</td>
<td style="text-align:center">24</td>
<td style="text-align:center">24</td>
<td style="text-align:center">24</td>
<td style="text-align:center">24</td>
<td style="text-align:center">23</td>
<td style="text-align:center">23</td>
<td style="text-align:center">23</td>
<td style="text-align:center">23</td>
<td style="text-align:center">22</td>
</tr>
<tr>
<td style="text-align:center">倪</td>
<td style="text-align:center">鮑</td>
<td style="text-align:center">崔</td>
<td style="text-align:center">柯</td>
<td style="text-align:center">顬</td>
<td style="text-align:center">上</td>
<td style="text-align:center">虞</td>
<td style="text-align:center">賈</td>
<td style="text-align:center">闉</td>
<td style="text-align:center">費</td>
<td style="text-align:center">湯</td>
<td style="text-align:center">萬</td>
<td style="text-align:center">于</td>
<td style="text-align:center">任</td>
<td style="text-align:center">施</td>
<td style="text-align:center">左</td>
<td style="text-align:center">查</td>
</tr>
<tr>
<td style="text-align:center">21</td>
<td style="text-align:center">20</td>
<td style="text-align:center">20</td>
<td style="text-align:center">20</td>
<td style="text-align:center">20</td>
<td style="text-align:center">20</td>
<td style="text-align:center">20</td>
<td style="text-align:center">19</td>
<td style="text-align:center">18</td>
<td style="text-align:center">17</td>
<td style="text-align:center">17</td>
<td style="text-align:center">17</td>
<td style="text-align:center">17</td>
<td style="text-align:center">16</td>
<td style="text-align:center">16</td>
<td style="text-align:center">16</td>
<td style="text-align:center">15</td>
</tr>
<tr>
<td style="text-align:center">喬</td>
<td style="text-align:center">姜</td>
<td style="text-align:center">凌</td>
<td style="text-align:center">柳</td>
<td style="text-align:center">饒</td>
<td style="text-align:center">易</td>
<td style="text-align:center">應</td>
<td style="text-align:center">莊</td>
<td style="text-align:center">梅</td>
<td style="text-align:center">齊</td>
<td style="text-align:center">司</td>
<td style="text-align:center">晏</td>
<td style="text-align:center">尹</td>
<td style="text-align:center">游</td>
<td style="text-align:center">臧</td>
<td style="text-align:center">晁</td>
<td style="text-align:center">段</td>
</tr>
<tr>
<td style="text-align:center">15</td>
<td style="text-align:center">14</td>
<td style="text-align:center">14</td>
<td style="text-align:center">14</td>
<td style="text-align:center">14</td>
<td style="text-align:center">14</td>
<td style="text-align:center">14</td>
<td style="text-align:center">14</td>
<td style="text-align:center">13</td>
<td style="text-align:center">13</td>
<td style="text-align:center">13</td>
<td style="text-align:center">13</td>
<td style="text-align:center">13</td>
<td style="text-align:center">13</td>
<td style="text-align:center">13</td>
<td style="text-align:center">12</td>
<td style="text-align:center">12</td>
</tr>
<tr>
<td style="text-align:center">關</td>
<td style="text-align:center">莫</td>
<td style="text-align:center">龐</td>
<td style="text-align:center">盛</td>
<td style="text-align:center">祝</td>
<td style="text-align:center">包</td>
<td style="text-align:center">樊</td>
<td style="text-align:center">管</td>
<td style="text-align:center">華</td>
<td style="text-align:center">武</td>
<td style="text-align:center">伍</td>
<td style="text-align:center">白</td>
<td style="text-align:center">畢</td>
<td style="text-align:center">聶</td>
<td style="text-align:center">丘</td>
<td style="text-align:center">韋</td>
<td style="text-align:center">衛</td>
</tr>
<tr>
<td style="text-align:center">12</td>
<td style="text-align:center">12</td>
<td style="text-align:center">12</td>
<td style="text-align:center">12</td>
<td style="text-align:center">12</td>
<td style="text-align:center">11</td>
<td style="text-align:center">11</td>
<td style="text-align:center">11</td>
<td style="text-align:center">11</td>
<td style="text-align:center">11</td>
<td style="text-align:center">11</td>
<td style="text-align:center">10</td>
<td style="text-align:center">10</td>
<td style="text-align:center">10</td>
<td style="text-align:center">10</td>
<td style="text-align:center">10</td>
<td style="text-align:center">10</td>
</tr>
</tbody>
</table>
<p>把前十名拿出来，做个地理分布可视化。</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">jinshi</span><span class="o">$</span><span class="n">FamilyName</span> <span class="o">&lt;-</span> <span class="n">fam.name</span>
</span></span><span class="line"><span class="cl"><span class="nf">for </span><span class="p">(</span><span class="n">famName</span> <span class="n">in</span> <span class="nf">c</span><span class="p">(</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#34;王&#34;</span><span class="p">,</span> <span class="s">&#34;李&#34;</span><span class="p">,</span> <span class="s">&#34;瀳&#34;</span><span class="p">,</span> <span class="s">&#34;隇&#34;</span><span class="p">,</span> <span class="s">&#34;劉&#34;</span><span class="p">,</span> <span class="s">&#34;吳&#34;</span><span class="p">,</span> <span class="s">&#34;楊&#34;</span><span class="p">,</span> <span class="s">&#34;黃&#34;</span><span class="p">,</span> <span class="s">&#34;林&#34;</span><span class="p">,</span> <span class="s">&#34;周&#34;</span><span class="p">)){</span>
</span></span><span class="line"><span class="cl">    <span class="n">pp</span> <span class="o">&lt;-</span> <span class="n">p.chn</span> <span class="o">+</span> <span class="nf">geom_point</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">x_coord</span><span class="p">,</span> <span class="n">y_coord</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">        <span class="n">data</span><span class="o">=</span><span class="n">jinshi[jinshi</span><span class="o">$</span><span class="n">FamilyName</span><span class="o">==</span><span class="n">famName</span><span class="p">,</span><span class="n">]</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">            <span class="n">color</span><span class="o">=</span><span class="s">&#34;blue&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.2</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="m">0.5</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">        <span class="nf">stat_density_2d</span><span class="p">(</span><span class="nf">aes</span><span class="p">(</span><span class="n">x_coord</span><span class="p">,</span> <span class="n">y_coord</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="n">..level..</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">                        <span class="n">data</span><span class="o">=</span><span class="n">jinshi[jinshi</span><span class="o">$</span><span class="n">FamilyName</span><span class="o">==</span><span class="n">famName</span><span class="p">,</span><span class="n">]</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">                        <span class="n">geom</span><span class="o">=</span><span class="s">&#34;polygon&#34;</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="m">0.5</span><span class="p">)</span> <span class="o">+</span>
</span></span><span class="line"><span class="cl">        <span class="nf">scale_fill_gradient</span><span class="p">(</span><span class="n">low</span><span class="o">=</span><span class="s">&#34;cyan&#34;</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="s">&#34;darkblue&#34;</span><span class="p">)</span><span class="o">+</span>
</span></span><span class="line"><span class="cl">        <span class="nf">ggtitle</span><span class="p">(</span><span class="nf">paste0</span><span class="p">(</span><span class="s">&#34;北宋、明、清&#34;</span><span class="p">,</span> <span class="n">fam.name</span><span class="p">,</span> <span class="s">&#34;姓进士来源地&#34;</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">    <span class="nf">print</span><span class="p">(</span><span class="n">pp</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></td></tr></table>
</div>
</div><figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Wang.png"/><figcaption>
            <h4>图 | 王姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Li.png"/><figcaption>
            <h4>图 | 李姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Zhang.png"/><figcaption>
            <h4>图 | 张姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Chen.png"/><figcaption>
            <h4>图 | 陈姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Liu.png"/><figcaption>
            <h4>图 | 刘姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Wu.png"/><figcaption>
            <h4>图 | 吴姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Yang.png"/><figcaption>
            <h4>图 | 杨姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Huang.png"/><figcaption>
            <h4>图 | 黄姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Lin.png"/><figcaption>
            <h4>图 | 林姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Zhou.png"/><figcaption>
            <h4>图 | 周姓进士来源</h4>
        </figcaption>
</figure>
<p>哈，都是全国性的大姓，所以热点来自五湖四海。唯一的例外是“林”，基本上就是福建一地。</p>
<p>受此启发，看一下“钱”、“沈”、“陆”。果然是无锡钱、吴兴沈、苏州陆。</p>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Qian.png"/><figcaption>
            <h4>图 | 钱姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Shen.png"/><figcaption>
            <h4>图 | 沈姓进士来源</h4>
        </figcaption>
</figure>
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/2017/0423/Jinshi_Lu.png"/><figcaption>
            <h4>图 | 陆姓进士来源</h4>
        </figcaption>
</figure>
<p>姓氏地理分析意思相对不是那么大。差不多是各姓氏的随机抽样。</p>
<p>数据集和分析代码都存着。以后想到什么好玩的，还可以继续玩。</p>
<p>[完]</p>
<hr>
<!-- {% raw %} -->
<figure class="center"><img src="https://gh-1251443721.cos.ap-chengdu.myqcloud.com/QRcode.jpg"
         alt="扫码关注" width="30%"/><figcaption>
            <h4>扫码关注我的公众号</h4>
        </figcaption>
</figure>
<!-- {% endraw %} -->
    </div>

    <div class="post-copyright">
  <p class="copyright-item">
    <span class="item-title">文章作者</span>
    <span class="item-content">迷幻主义搬砖号子</span>
  </p>
  <p class="copyright-item">
    <span class="item-title">上次更新</span>
    <span class="item-content">
        2021-05-09
        <a href="https://github.com/madlogos/hugo-blog.git/commit/f3e8c5ae54f54c3eea5e759b3bce5a3facc97c88" title="changes on 2021年 5月 9日 星期日 21时28分26秒 CST">(f3e8c5a)</a>
    </span>
  </p>
  <p class="copyright-item">
      <span class="item-title">原始文档</span>
      <span class="item-content"><a class="link-to-markdown" href="https://madlogos.github.io/post/song_ming_qing_jinshi/index.md" target="_blank">查看本文 Markdown 版本 »</a></span>
    </p>
  <p class="copyright-item">
    <span class="item-title">许可协议</span>
    <span class="item-content"><a rel="license noopener" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank">CC BY-NC-ND 4.0</a></span>
  </p>
</div>
<div class="post-reward">
  <input type="checkbox" name="reward" id="reward" hidden />
  <label class="reward-button" for="reward">赞赏支持</label>
  <div class="qr-code">
    
    <label class="qr-code-image" for="reward">
        <img class="image" src="/img/reward/wechat.png">
        <span>微信打赏</span>
      </label>
    <label class="qr-code-image" for="reward">
        <img class="image" src="/img/reward/alipay.png">
        <span>支付宝打赏</span>
      </label>
  </div>
</div><footer class="post-footer">
      <div class="post-tags">
          <a href="/tags/%E8%BF%9B%E5%A3%AB/">进士</a>
          <a href="/tags/%E5%9C%B0%E7%90%86%E5%88%86%E6%9E%90/">地理分析</a>
          </div>
      <nav class="post-nav">
        <a class="prev" href="/post/song_ming_qing_jinshi_interactive/">
            <i class="iconfont icon-left"></i>
            <span class="prev-text nav-default">【动态图版】北宋、明清进士空间可视化分析</span>
            <span class="prev-text nav-mobile">上一篇</span>
          </a>
        <a class="next" href="/post/infectdis_stat3/">
            <span class="next-text nav-default">一次不太成功的搬砖（下）：rvest爬取法定传染病疫情月报数据</span>
            <span class="next-text nav-mobile">下一篇</span>
            <i class="iconfont icon-right"></i>
          </a>
      </nav>
    </footer>
  </article>
        </div>
        <div id="disqus_thread"></div>
    <script type="text/javascript">
    (function() {
      
      
      if (window.location.hostname === 'localhost') return;

      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      var disqus_shortname = 'madlogos-gh';
      dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

  

  

      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="social-links">
      <a href="mailto:madlogos@gmail.com" class="iconfont icon-email" title="email"></a>
      <a href="https://stackoverflow.com/users/5455754/madlogos?tab=profile" class="iconfont icon-stack-overflow" title="stack-overflow"></a>
      <a href="https://twitter.com/madlogos" class="iconfont icon-twitter" title="twitter"></a>
      <a href="https://www.facebook.com/madlogos" class="iconfont icon-facebook" title="facebook"></a>
      <a href="http://www.linkedin.com/in/yiying-wang/" class="iconfont icon-linkedin" title="linkedin"></a>
      <a href="https://plus.google.com/&#43;%E6%B1%AA%E8%BD%B6%E9%A2%96madlogos" class="iconfont icon-google" title="google"></a>
      <a href="http://github.com/madlogos" class="iconfont icon-github" title="github"></a>
      <a href="https://weibo.com/madlogos/" class="iconfont icon-weibo" title="weibo"></a>
      <a href="https://www.zhihu.com/people/madlogos/" class="iconfont icon-zhihu" title="zhihu"></a>
      <a href="https://www.douban.com/people/Jandeaux/" class="iconfont icon-douban" title="douban"></a>
      <a href="https://jandeaux.tumblr.com" class="iconfont icon-tumblr" title="tumblr"></a>
      <a href="https://www.instagram.com/jandeaux/" class="iconfont icon-instagram" title="instagram"></a>
      <a href="https://gitlab.com/madlogos" class="iconfont icon-gitlab" title="gitlab"></a>
      <a href="https://space.bilibili.com/384080442" class="iconfont icon-bilibili" title="bilibili"></a>
  <a href="https://madlogos.github.io/index.xml" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a>
</div>

<div class="copyright">
  <span class="power-by">
    由 <a class="hexo-link" href="https://gohugo.io">Hugo</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 - 
    <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
  </span>

  <div class="busuanzi-footer">
    <span id="busuanzi_container_site_pv"> 本站总访问量 <span id="busuanzi_value_site_pv"><img src="/img/spinner.svg" alt="spinner.svg"/></span> 次 </span>
      <span class="division">|</span>
    <span id="busuanzi_container_site_uv"> 本站总访客数 <span id="busuanzi_value_site_uv"><img src="/img/spinner.svg" alt="spinner.svg"/></span> 人 </span>
  </div>

  <span class="copyright-year">
    &copy; 
    2017 - 
    2022
    
    <span class="author">madlogos</span>
  </span>
</div>

    </footer>

    <div class="back-to-top" id="back-to-top">
      <i class="iconfont icon-up"></i>
    </div>
  </div>
  
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js" integrity="sha256-yt2kYMy0w8AbtF89WXb2P1rfjcP/HTHLT7097U8Y5b8=" crossorigin="anonymous"></script><script></script><script src="https://cdn.jsdelivr.net/npm/raphael@2.3.0/raphael.min.js" integrity="sha256-TabprKdeNXbSesCWLMrcbWSDzUhpAdcNPe5Q53rn9Yg=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/flowchart.js@1.12.1/release/flowchart.min.js" integrity="sha256-ANSuVJkHZftRURALG24omixaZG+Sb51/+JY6EDa7MdE=" crossorigin="anonymous"></script><script></script><script src="https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/snapsvg@0.5.1/dist/snap.svg-min.js" integrity="sha256-oI+elz+sIm+jpn8F/qEspKoKveTc5uKeFHNNVexe6d8=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/underscore@1.10.2/underscore-min.js" integrity="sha256-av1TvywtZ4ZqyCj/6HdtCHSJdn80HAzTgEBTJt/O8uc=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/@rokt33r/js-sequence-diagrams@2.0.6-2/dist/sequence-diagram-min.js" integrity="sha256-eadHf9g1REH9Wvp2FLV/D9vKNvQUFKuVPgWFvmMQxBE=" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@rokt33r/js-sequence-diagrams@2.0.6-2/dist/sequence-diagram-min.css" integrity="sha256-On01v36B8LRDuL2tqhqs7Gb3Cm/NIpsLFy4OarOodUA=" crossorigin="anonymous">



<script type="text/javascript" src="/js/main.min.4ae89da218555efa0e7093a20b92017d2e1202b66fff9fc2edf4cb8d44b44c6e.js"></script>
  <script type="text/javascript">
    window.MathJax = {
      tex: {
        inlineMath: [['$','$'], ['\\(','\\)']],
        tags: 'ams',
        }
    };
  </script>
  <script async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-mml-chtml.js" integrity="sha256-HGLuEfFcsUJGhvB8cQ8nr0gai9EucOOaIxFw7qxmd+w=" crossorigin="anonymous"></script>


<script type="application/javascript">
var doNotTrack = false;
if (!doNotTrack) {
	window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
	ga('create', 'UA-68964085-2', 'auto');
	ga('set', 'anonymizeIp', true);
	ga('send', 'pageview');
}
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<script id="baidu_analytics">
  var _hmt = _hmt || [];
  (function() {
    if (window.location.hostname === 'localhost') return;
    var hm = document.createElement("script"); hm.async = true;
    hm.src = "https://hm.baidu.com/hm.js?f221e23428218df65adeefe00f85e7ed";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
  })();
</script>

<script id="baidu_push">
  (function(){
    if (window.location.hostname === 'localhost') return;
    var bp = document.createElement('script'); bp.async = true;
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
      bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
      bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
  })();
</script>


<script src="/js/custom.js"></script>


</body>
</html>
